package adv8;

import java.beans.XMLEncoder;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class ObjToXML {

	public static void main(String[] args) throws IOException {
		// 对象转换成xml
		List<Product> list = new ArrayList<>();
		for (int i = 1; i <= 5; i++) {
			list.add(new Product(1000L + i, "南京", "瓜子" + i, "袋", 4.5, 100 + i, false));
		}
		XMLEncoder xd = new XMLEncoder(new FileOutputStream("guazi.xml"));
		xd.writeObject(list);
		xd.close();
	}

}
